package cn.crex1.xiaomi.core.mvc.beans.config;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class BeanDefinitionUtil {

	/**
	 * 判断是否存在指定注解
	 * @param annoClass
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public static boolean isAnnotation(Class<? extends Annotation> annoClass,Class<?> beanClass) {
		if (beanClass.isAnnotationPresent(annoClass)) {
			return true;
		}
		return false;
	}
	public static boolean isAnnotation(Class<? extends Annotation> annoClass,Method beanMethod) {
		if (beanMethod.isAnnotationPresent(annoClass)) {
			return true;
		}
		return false;
	}
	public static boolean isAnnotation(Class<? extends Annotation> annoClass,Field beanField) {
		if (beanField.isAnnotationPresent(annoClass)) {
			return true;
		}
		return false;
	}
	/**
	 * 生成beanName
	 * @param beanClass
	 * @return
	 */
	public static String generateClassName(Class<?> beanClass) {
		StringBuffer sb=new StringBuffer();
		String beanClassName = beanClass.getSimpleName();
		sb.append(beanClassName.substring(0, 1).toLowerCase()).append(beanClassName.substring(1));
		return sb.toString();		
	}
}
